<?php
class Employee extends AppModel {
	var $name = 'Employee';
	var $displayField = 'name';
	
	public $actsAs = array('Searchable');
	public $filterArgs = array(
		array('name' => 'name', 'type' => 'like'),
		array('name' => 'surname', 'type' => 'like'),
		array('name' => 'address1', 'type' => 'like'),
		array('name' => 'address3', 'type' => 'like'),
		array('name' => 'address4', 'type' => 'like'),
		array('name' => 'address5', 'type' => 'like'),
		array('name' => 'phone1', 'type' => 'like'),
		array('name' => 'ssn_irs', 'type' => 'like'),
		array('name' => 'numer_id', 'type' => 'like'),
		array('name' => 'type_of_work_id', 'type' => 'value')
	);	
		
	var $validate = array(
		'email' => array( 
       		'rule' => 'notEmpty',
        	'message' => 'This field cannot be left blank'
    	),
		'password' => array( 
       		'rule' => 'notEmpty',
        	'message' => 'This field cannot be left blank'
    	),
		'name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank'
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'surname' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank'
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'address1' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'address3' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank'
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'address4' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank'
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'phone1' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank'
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'ssn_irs' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank'
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'numer_id' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank'
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'type_of_work_id' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'This field cannot be left blank',
				'allowEmpty' => false
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
//		'date_of_employment' => array(
//			'date' => array(
//				'rule' => array('date','mdy'),
//		        'message' => 'Enter a valid date in MM-DD-YYYY format.',
//		        'allowEmpty' => false
//				//'required' => false,
//				//'last' => false, // Stop validation after this rule
//				//'on' => 'create', // Limit validation to 'create' or 'update' operations
//			),
//		),
//		'employment_end_date' => array(
//			'date' => array(
//				'rule' => array('date','mdy'),
//		        'message' => 'Enter a valid date in MM-DD-YYYY format.',
//		        'allowEmpty' => true
//				//'required' => false,
//				//'last' => false, // Stop validation after this rule
//				//'on' => 'create', // Limit validation to 'create' or 'update' operations
//			),
//		),
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $belongsTo = array(
		'User' => array(
			'className' => 'User',
			'foreignKey' => 'user_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'TypeOfWork' => array(
			'className' => 'TypeOfWork',
			'foreignKey' => 'type_of_work_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

	var $hasMany = array(
		'OrdersSeries' => array(
			'className' => 'OrdersSeries',
			'foreignKey' => 'employee_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);


	var $hasAndBelongsToMany = array(
		'Order' => array(
			'className' => 'Order',
			'joinTable' => 'orders_employees',
			'foreignKey' => 'employee_id',
			'associationForeignKey' => 'orders_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);

}
?>